<?php
// URL PARSING
$requri =  $_SERVER["REQUEST_URI"];
$requri_arr = explode('/',$requri);
echo '<div style="color: #FFFFFF;">';

$default_to_outword=0;
//first segment (siteurl only)
if(count($requri_arr) == 2){
	$member_url = $requri_arr[1];
		if($member_url!=""){
			
				//VALID FORMAT
				// preg_match("/^[a-z0-9]+$/i", $member_url);
				if(preg_match("/^[a-z0-9]*$/i", $member_url) > 0){
					//VALID, CHECK DB
					$siteqry = dbSelect('sites',array("siteurl='$member_url'"));
					if(mysql_numrows($siteqry) > 0){
						$site = mysql_fetch_array($siteqry);
						//echo '<br /> siteid: '.$site['id'];
					}else{
						$default_to_outword++;
						//echo '<br /> siteid: '.$site['id'];
						echo '<br />Sorry, but that site address is not registered.';
					}
				}else{
					$default_to_outword++;
					//echo '<br /> siteid: '.$site['id'];
					echo '<br />Sorry, but that address is not valid.';
				}
		}else{
			$default_to_outword++;
		}
//first and second segments (siteurl and page.php)
}elseif(count($requri_arr) == 3){
	$member_url = $requri_arr[1];
		if($member_url!=""){
			if(stripos($requri_arr[2],'.php') > 0){
				$page = explode('.php',$requri_arr[2]);
				$page_url = $page[0].'.php';
				//be sure this is a valid page and load it
				$page2load = $page_url;
				foreach($_GET as $var){
					$args[] = $var;
				}
				$default_to_outword++;
			}else{
				if(preg_match("/^[a-z0-9]+$/i", $member_url) > 0){
					//VALID, CHECK DB
					$siteqry = dbSelect('sites',array("siteurl='$member_url'"));
					if(mysql_numrows($siteqry) > 0){
						$site = mysql_fetch_array($siteqry);
						//echo '<br /> siteid: '.$site['id'];
					}else{
						$default_to_outword++;
						echo '<br />Sorry, but that address is not registered.';
					}
				}else{
					$default_to_outword++;
					echo '<br />Sorry, but that address is not valid.';
				}
			}
		}else{
			$default_to_outword++;
		}
		
	//$page_url = $requri_arr[2];
	//be sure this is a valid page and load it
	//$page2load = $page_url;
	//echo '<br />page: '.$page_url;
}
	if($default_to_outword > 0){
		$member_url = 'outword';
		$siteqry = dbSelect('sites',array("siteurl='$member_url'"));
		
		$site = mysql_fetch_array($siteqry);
		$siteid = $site['id'];
		//echo '<br />'.$site['siteurl'];
	}
echo '</div>';
if ( strpos($_SERVER['HTTP_USER_AGENT'], 'Gecko') ){
   if ( strpos($_SERVER['HTTP_USER_AGENT'], 'Netscape') ){
     $browser = 'NS';
   }else if ( strpos($_SERVER['HTTP_USER_AGENT'], 'Firefox') ){
     $browser = 'FF';
   }else{
     $browser = 'Moz';
   }
}else if ( strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') ){
   if ( strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') ){
     $browser = 'Opera (MSIE/Opera/Compatible)';
   }else{$browser = 'IE';}
}
else{$browser = 'Others browsers';}
//echo $browser;
?>